<?php

namespace App\Http\Controllers\Innerend;


use App\Models\SiteInfo;

class SiteInfoController extends BaseController
{

    // 话题
    public function initialize()
    {
        parent::initialize();

        $key = $this->optLogic()->getData('key', '', 'trim');
        $url = url('/innerend/site-info/content?key='.$key);

        $this->assign('init_url', $url);
        $this->model = 'SiteInfo';
    }

    // 父级
    // 添加，修改，删除，列表，停用 操作


    // 展示内容
    public function content()
    {
        $key = $this->optLogic()->getData('key', null, 'trim');
        $this->throwIf(empty($key), '请选择你要操作的数据！');

        $model = new SiteInfo();
        $info  = $model->isCache(true)->oneFind(['key' => $key]);
        $form  = $this->adminForm();

        $idHtml  = $form->formHidden('id', $info['id'] ?? 0);
        $keyHtml = $form->formHidden('key', $info['key'] ?? '');
        $title   = $form->formInput('title', $info['title'] ?? '', '标题');
        $content = $form->formUeditor('content', $info['content'] ?? '');
        //$content = $form->formTextarea('content', $info['content'] ?? '');

        $formHtml = $idHtml;
        $formHtml .= $keyHtml;
        $formHtml .= $form->makeItem('标题', $title);
        $formHtml .= $form->makeItem('内容', $content);

        var_dump($this->optLogic()->getUser());

        return $this->dispaly('form', ['formHtml' => $formHtml]);
    }

}


